<?php
/**
 * @author: xaboy<365615158@qq.com>
 * @day: 2017/11/11
 */

namespace app\merchant\model\agent;

use crmeb\basic\BaseModel;
use app\models\store\StoreCart;
use crmeb\services\PHPExcelService;
use crmeb\traits\ModelTrait;


/**
 * 产品管理 model
 * Class StoreProduct
 * @package app\admin\model\store
 */
class Ranking extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'ranking';

    use ModelTrait;



    /*
    * 设置搜索条件
    *
    */
    public static function setWhere($where)
    {

        if ($where['type']) {
            $model = self::where('type', $where['type']);
        }
        if ($where['rank_time']) {
            $model = $model->where('rank_time', $where['rank_time']);
        }
        if (isset($where['mer_id']) && $where['mer_id'] != '') {
            $model = $model->where('mer_id', $where['mer_id']);
        }
        return $model;
    }

    /**
     * 异步获取当前用户 信息
     * @param $where
     * @return array
     */
    public static function getUserList($where)
    {
        $model = self::setWhere($where);
        $list = $model
            ->page((int)$where['page'], (int)$where['limit'])
            ->select();
        $count = self::setWhere($where)->count();
        return ['count' => $count, 'data' => $list];
    }



}